﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace WMS.Common
{
    public static  class MD5Helper
    {
        // <summary>
        /// 对密码进行MD5加密
        /// </summary>
        /// <param name="password">明文密码</param>
        /// <returns>MD5加密后的密码</returns>
        public static string EncryptPassword(string password)
        {
            if (string.IsNullOrWhiteSpace(password))
                throw new ArgumentException("密码不能为空");

            using (var md5 = MD5.Create())
            {
                byte[] data = md5.ComputeHash(Encoding.UTF8.GetBytes(password));
                return BitConverter.ToString(data).Replace("-", "").ToLower();
            }
        }
    }
}
